﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using UnityEngine;

public class _15 : MonoBehaviour
{


    // Start is called before the first frame update
    void Start()
    {
        //DynamicSample dynamicSample = new DynamicSample();
        //var addMethod = typeof(DynamicSample).GetMethod("Add");
        //int re = (int)addMethod.Invoke(dynamicSample, new object[] { 1, 2 });
        //Debug.LogError("###1 = " + re);


        dynamic dynamicSample2 = new DynamicSample();
        int re2 = dynamicSample2.Add(1, 2);
        Debug.LogError(re2);
        Debug.LogError(dynamicSample2.Name);
    }

    // Update is called once per frame
    void Update()
    {

    }
    public class DynamicSample
    {
        public dynamic GetData()
        {
            return this;
        }

        public string Name { get; set; }

        public DynamicSample() { }

        public int Add(int a, int b)
        {
            return a + b;
        }
    }
}
